﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using MVPlan.Engine.Gases;
using MVPlan.Engine.Segment;

namespace MVPlan.UnitTest
{
    /// <summary>
    /// Summary description for SegmentAbstractTest
    /// </summary>
    [TestClass]
    public class SegmentAbstractTest
    {
        public SegmentAbstractTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        protected SegmentAbstract GetSegment(double setpoint)
        {
            SegmentAbstract seg = new SegmentAbstract();

            seg.Depth = 10;
            seg.Gas = new Gas(0.21, 0);
            seg.Setpoint = setpoint;
            seg.Time = 5;

            return seg;              
        }

        [TestMethod]
        public void TestCalcs()
        {
            SegmentAbstract air = GetSegment(0);

            Assert.AreEqual<double>(10, air.END, "END Incorrect.");
            Assert.AreEqual<double>(0.42, air.PPO2, "PPO2 Incorrect.");
            Assert.AreEqual<double>(1.58, air.PPN2, "PPN2 Incorrect.");
            Assert.AreEqual<SegmentMode>(SegmentMode.OC, air.Mode, "Segment Mode Incorrect.");

            air.Setpoint = 1.3;

            Assert.AreEqual<SegmentMode>(SegmentMode.CCR, air.Mode, "Segment Mode Incorrect.");
        }
    }
}
